<!DOCTYPE html>
<html
  lang="zh"
  xmlns:th="http://www.thymeleaf.org"
  xmlns:shiro="http://www.pollix.at/thymeleaf/shiro"
>
  <head>
    <th:block th:include="include :: header('修改PK对战')" />
  </head>
  <body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
      <div class="row">
        <div class="col-sm-12">
          <div class="ibox float-e-margins">
            <div class="ibox-title">
              <h5>修改PK对战</h5>
            </div>
            <div class="ibox-content">
              <form
                class="form-horizontal m"
                id="form-pk-edit"
                th:object="${pkBattle}"
              >
                <input name="id" th:field="*{id}" type="hidden" />
                <div class="form-group">
                  <label class="col-sm-3 control-label">对战编号：</label>
                  <div class="col-sm-8">
                    <input
                      name="battleNo"
                      th:field="*{battleNo}"
                      class="form-control"
                      type="text"
                      required
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">发起者ID：</label>
                  <div class="col-sm-8">
                    <input
                      name="initiatorId"
                      th:field="*{initiatorId}"
                      class="form-control"
                      type="number"
                      required
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">应战者ID：</label>
                  <div class="col-sm-8">
                    <input
                      name="challengerId"
                      th:field="*{challengerId}"
                      class="form-control"
                      type="number"
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">配置ID：</label>
                  <div class="col-sm-8">
                    <input
                      name="configId"
                      th:field="*{configId}"
                      class="form-control"
                      type="number"
                      required
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">对战状态：</label>
                  <div class="col-sm-8">
                    <select
                      name="battleStatus"
                      th:field="*{battleStatus}"
                      class="form-control"
                      required
                    >
                      <option value="1">等待应战</option>
                      <option value="2">对战中</option>
                      <option value="3">已结束</option>
                    </select>
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">获胜者ID：</label>
                  <div class="col-sm-8">
                    <input
                      name="winnerId"
                      th:field="*{winnerId}"
                      class="form-control"
                      type="number"
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">开始时间：</label>
                  <div class="col-sm-8">
                    <input
                      name="startTime"
                      th:field="*{startTime}"
                      class="form-control"
                      type="datetime-local"
                    />
                  </div>
                </div>
                <div class="form-group">
                  <label class="col-sm-3 control-label">结束时间：</label>
                  <div class="col-sm-8">
                    <input
                      name="endTime"
                      th:field="*{endTime}"
                      class="form-control"
                      type="datetime-local"
                    />
                  </div>
                </div>
                <div class="form-group">
                  <div class="form-control-static col-sm-offset-9">
                    <button type="submit" class="btn btn-primary">提交</button>
                    <button
                      type="button"
                      class="btn btn-danger"
                      onclick="closeItem()"
                    >
                      关闭
                    </button>
                  </div>
                </div>
              </form>
            </div>
          </div>
        </div>
      </div>
    </div>

    <th:block th:include="include :: footer" />

    <script type="text/javascript">
      var prefix = ctx + "system/exam/pk";

      $("#form-pk-edit").validate({
        rules: {
          battleNo: {
            required: true,
            maxlength: 32,
          },
          initiatorId: {
            required: true,
            digits: true,
          },
        },
        messages: {
          battleNo: {
            required: "请输入对战编号",
            maxlength: "对战编号不能超过32个字符",
          },
          initiatorId: {
            required: "请输入发起者ID",
            digits: "发起者ID必须为整数",
          },
        },
        submitHandler: function (form) {
          $.operate.save(prefix + "/edit", $("#form-pk-edit").serialize());
        },
      });

      function closeItem() {
        var index = parent.layer.getFrameIndex(window.name);
        parent.layer.close(index);
      }
    </script>
  </body>
</html>
